home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 58.5 KB | 1,918 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFrame.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWFRMINF_H
- #include "FWFrmInf.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWEDCMD_H
- #include "FWEdCmd.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWGADGET_H
- #include "FWGadget.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCLNINF_H
- #include "FWClnInf.h"
- #endif
-
- #ifndef FWCNTRHW_H
- #include "FWCntrHW.h"
- #endif
-
- #ifndef FWVIEWAS_H
- #include "FWViewAs.h"
- #endif
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWSCLNOT_H
- #include "FWSclNot.h"
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODMISS_H
- #include "FWODMiss.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGDEV_H
- #include "FWGDev.h"
- #endif
-
- #ifndef FWMACOS_H
- #include "FWMacOS.h"
- #endif
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- #if !defined(FWGRMATH_H) && defined(FW_BUILD_WIN)
- #include "FWGrMarh.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_FrameSegment
- #endif
-
- FW_DEFINE_CLASS_M3(FW_CFrame, FW_CView, FW_MDragDroppable, FW_MIdle);
-
- //========================================================================================
- // class FW_CFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FW_CFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame::FW_CFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_CPart* part) :
- FW_MDragDroppable(ev, part),
- FW_CView(ev),
- FW_MIdle(part, this),
- fPart(part),
- fContentView(NULL),
- fGetFrontClicks(TRUE),
- fActiveFacet(NULL),
- fCanBeActiveFrame(TRUE),
- fFocusSet(ev, part->GetSession(ev)),
- fChangedFocusSet(ev, part->GetSession(ev)),
- fFocusSetChanged(FALSE),
- fNeedsFoci(FALSE),
- fPresentation(presentation),
- fWindow(NULL),
- fFacetCount(0),
- fODFrame(odFrame),
- fPreviousViewType(odFrame->GetViewType(ev)),
- fViewAs(NULL),
- fConnection(NULL),
- fViewUnderCursor(NULL),
- fScrollingViews(NULL),
- fContentViewLocation(FW_kZeroPoint)
- #ifdef FW_BUILD_WIN
- ,fShadowWindow(NULL)
- #endif
- {
- FW_ASSERT(fODFrame);
-
- fTarget = this;
-
- this->SetNextEventHandler(ev, part);
-
- fNeedsFoci = odFrame->IsRoot(ev);
-
- // ----- By default we put all of them
- // Note: If the containing window is a floating window I will remove
- // them in facet added.
- fFocusSet.Add(ev, FW_CPart::gKeyFocusToken);
- fFocusSet.Add(ev, FW_CPart::gMenuFocusToken);
- fFocusSet.Add(ev, FW_CPart::gSelectionFocusToken);
- fFocusSet.Add(ev, FW_CPart::gClipboardFocusToken);
-
- SetIdentifier(ev, fPresentation->GetPresentationType(ev));
-
- // ----- force to be view as frame if root -----
- if (fPreviousViewType != FW_CPart::gViewAsFrameToken && IsRoot(ev))
- fODFrame->SetViewType(ev, FW_CPart::gViewAsFrameToken);
-
- // ----- Set the frame's view Bounds to its shape bounds
- FW_CRect frameRect;
- PrivGetFrameShapeBounds(ev, frameRect);
- PrivSetBounds(ev, frameRect);
- PrivSetExtent(ev, frameRect.Size());
-
- // ----- By default the frame is equal to its ContentView
- PrivSetIsContentView(ev, TRUE);
- fContentView = (FW_CView*)this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::~FW_CFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame::~FW_CFrame()
- {
- Environment* ev = somGetGlobalEnvironment();
-
- FW_ASSERT(IsRegisteredForIdle(ev) == FALSE);
-
- FW_ASSERT(fWindow == NULL); // should have been deleted in FrameRemoved
-
- if (fViewAs && fPresentation)
- fPresentation->ReleaseViewAs(ev, fViewAs);
-
- if (fConnection) {
- fConnection->RemoveAllInterests(); // [LSD] necessary?
- delete fConnection;
- fConnection = NULL;
- }
-
- // deletes its ContentView first to make sure that the scroller is deleted before
- // the scrollbars (otherwise ~FW_CView deletes views in reverse order of creation)
- if (IsContentView(ev) == FALSE) {
- delete GetContentView(ev);
- }
-
- if (fScrollingViews) {
- delete fScrollingViews;
- fScrollingViews = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivCreateWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::PrivCreateWindow(Environment* ev, ODWindow* odWindow)
- {
- FW_ASSERT(odWindow);
- FW_ASSERT(fWindow == NULL || fWindow->GetID(ev) == odWindow->GetID(ev));
-
- if (fWindow == NULL)
- {
- ODPlatformWindow platformWindow = odWindow->GetPlatformWindow(ev);
-
- FW_CWindow* fwWindow = NULL;
-
- if (IsRoot(ev))
- {
- #ifdef FW_BUILD_MAC
- fwWindow = (FW_CWindow*) ::GetWRefCon(platformWindow);
- #endif
-
- #ifdef FW_BUILD_WIN
- fwWindow = (FW_CWindow*) ::GetProp(platformWindow, "ODF:Window");
- #endif
- }
-
- if (fwWindow != NULL)
- fWindow = fwWindow;
- else
- fWindow = new FW_CWindow(ev, fPart->GetODPart(ev), odWindow->GetID(ev));
- }
-
- return fWindow;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameRemoved
- //----------------------------------------------------------------------------------------
- // Notification
-
- void FW_CFrame::FrameRemoved(Environment* ev, FW_Boolean toStorage)
- {
- FW_UNUSED(toStorage);
-
- if (toStorage)
- UnregisterIdle(ev);
-
- // ----- Relinquish what ever focus we have
- fFocusSet.RelinquishFocusSet(ev, GetODFrame(ev));
-
- // ----- Check that the window has been deleted -----
- FW_ASSERT(fFacetCount == 0);
- FW_ASSERT(fWindow == NULL); // When the frame is removed it should not have any facets. fWindow
- // should already be null (see FacetRemoved)
-
- // ----- delete the partInfo -----
- FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)fODFrame->GetPartInfo(ev);
- fODFrame->SetPartInfo(ev, NULL);
- delete framePartInfo;
-
- fPresentation->PrivRemoveFrame(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameAdded
- //----------------------------------------------------------------------------------------
- // Notification
-
- void FW_CFrame::FrameAdded(Environment* ev, FW_Boolean fromStorage)
- {
- FW_UNUSED(ev);
- FW_UNUSED(fromStorage);
-
- // ----- Add it to the presentation -----
- fPresentation->PrivAddFrame(ev, this);
-
- // ----- Initialize printing handler -----
- FW_CPrintHandler* printHandler = NewPrintHandler(ev);
- if (printHandler != NULL)
- AdoptEventHandler(ev, printHandler);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PageEmbeddedFrames
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PageEmbeddedFrames(Environment* ev)
- {
- // Doesn't do anything because not embedding
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetODStorageUnitID
- //----------------------------------------------------------------------------------------
-
- ODStorageUnitID FW_CFrame::GetODStorageUnitID(Environment* ev) const
- {
- ODStorageUnit* storageUnit = fODFrame->GetStorageUnit(ev);
-
- return storageUnit != NULL ? storageUnit->GetID(ev) : kODNULLID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetTarget
- //----------------------------------------------------------------------------------------
-
- FW_MEventHandler* FW_CFrame::GetTarget(Environment* ev) const
- {
- return fTarget;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetTarget
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetTarget(Environment* ev, FW_MEventHandler* theTarget)
- {
- fTarget = theTarget;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::WantsToBeTarget
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::WantsToBeTarget(Environment* ev)
- {
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean result = TRUE;
- FW_CEditCommand* cmd;
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
-
- switch (commandID)
- {
- case kODCommandViewAsWin:
- fPresentation->ViewInWindow(ev, this, NULL);
- break;
-
- case kODCommandCut:
- case kODCommandCopy:
- case kODCommandPaste:
- case kODCommandPasteAs:
- case kODCommandClear:
- cmd = this->NewEditCommand(ev, commandID);
- if (cmd)
- GetPart(ev)->ExecuteCommand(ev, cmd);
- break;
-
- case kODCommandSelectAll:
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- if (selection)
- selection->SelectAll(ev);
- break;
-
- default:
- result = FW_CView::HandleMenu(ev, theMenuEvent);
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetDragging
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetDragging(Environment* ev, FW_Boolean dragging)
- {
- fODFrame->SetDragging(ev, dragging);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetDroppable
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetDroppable(Environment* ev, FW_Boolean droppable)
- {
- fODFrame->SetDroppable(ev, droppable);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewPartWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::NewPartWindow(Environment* ev, ODFacet* sourceFacet)
- {
- FW_CRect frameBounds = GetBounds(ev);
- FW_CAcquiredODTransform transform = sourceFacet->AcquireWindowFrameTransform(ev, NULL);
- frameBounds.Transform(ev, transform);
- GetWindow(ev)->WindowToScreen(ev, frameBounds);
- frameBounds.Offset(FW_IntToFixed(20), FW_IntToFixed(20));
-
- FW_CString255 partName;
- fPart->GetPartName(ev, partName);
-
- return new FW_CWindow(ev,
- fPart->GetODPart(ev),
- fODFrame,
- FALSE, // persistent frame
- FW_CPart::gViewAsFrameToken,
- GetPresentation(ev)->GetPresentationType(ev),
- partName,
- frameBounds.Size(),
- frameBounds.TopLeft(),
- FW_kDocumentWindow);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewEditCommand
- //----------------------------------------------------------------------------------------
-
- FW_CEditCommand* FW_CFrame::NewEditCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(FW_CEditCommand, (ev,
- commandID,
- this,
- FW_kCantUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::InstallMenus
- //----------------------------------------------------------------------------------------
- // By default call the part with a null menuBar
-
- void FW_CFrame::InstallMenus(Environment *ev)
- {
- GetPart(ev)->InstallMenus(ev, NULL); // will install the part menubar
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleWindowEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent)
- {
- FW_Boolean handled = TRUE;
-
- unsigned long message = windowEvent.GetMessage();
- switch (windowEvent.GetMessage())
- {
- case inZoomIn:
- case inZoomOut:
- {
- ODPlatformWindow platformWindow = GetWindow(ev)->GetPlatformWindow(ev);
-
- // ----- Get the size of the window border -----
- FW_CRect borderSize;
- FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
-
- // ----- Find out where the window would like to be zoomed out to
- FW_CRect screenRect;
- ::FW_MacGetMaxIntersectedDevice(platformWindow, screenRect);
- screenRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3)); // leave space around window structure area
-
- // ----- call the part to get a custom size (interior size) -----
- FW_CPoint proposedSize(screenRect.Width() - borderSize.left - borderSize.right,
- screenRect.Height() - borderSize.top - borderSize.bottom);
- this->AdjustZoomedWindowSize(ev, proposedSize);
-
- fWindow->PrivMacDoZoom(ev, proposedSize, borderSize, screenRect, message);
- }
- break;
-
- case inGrow:
- {
- FW_CRect growLimits(FW_IntToFixed(64), FW_IntToFixed(64), FW_IntToFixed(32000), FW_IntToFixed(32000));
- this->AdjustWindowGrowLimits(ev, growLimits[FW_kTopLeft], growLimits[FW_kBotRight]);
-
- // If minimum is lareger than maximun then do something
- if (growLimits.left > growLimits.right)
- growLimits.left = growLimits.right;
- if (growLimits.top > growLimits.bottom)
- growLimits.top = growLimits.bottom;
-
- fWindow->PrivMacTrackResizeWindow(ev, growLimits, windowEvent);
- }
- break;
-
- case inGoAway:
- if (fWindow->IsFloating(ev))
- fWindow->Hide(ev);
- else
- handled = FALSE;
- break;
-
- default:
- handled = FALSE;
- }
-
- return handled;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustZoomedWindowSize
- //----------------------------------------------------------------------------------------
- // proposedSize is the interior size of the window
-
- void FW_CFrame::AdjustZoomedWindowSize(Environment *ev, FW_CPoint& proposedSize)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustWindowGrowLimits
- //----------------------------------------------------------------------------------------
- // proposedSize is the interior size of the window
-
- void FW_CFrame::AdjustWindowGrowLimits(Environment *ev, FW_CPoint& minSize, FW_CPoint& maxSize)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleAdjustMenus(Environment *ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- // ----- Only if I am the target -----
- if (GetTarget(ev) == this)
- {
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- FW_Boolean hasSelection = selection && !selection->IsEmpty(ev);
-
- // ----- Edit Menu -----
- // If read only clear, cut past items will be disabled in FW_CPart::HandleAdjustMenus
- menuBar->EnableCommand(ev, kODCommandClear, hasSelection);
- menuBar->EnableCommand(ev, kODCommandCut, hasSelection);
- menuBar->EnableCommand(ev, kODCommandCopy, hasSelection);
- menuBar->EnableCommand(ev, kODCommandPaste, FALSE);
-
- menuBar->EnableCommand(ev, kODCommandPasteAs, HasPropertyOnClipboard(ev, kODPropLinkSpec, kODLinkSpec));
- }
-
- menuBar->EnableCommand(ev, kODCommandViewAsWin, !IsTopFrame(ev));
- }
-
- return FW_CView::HandleAdjustMenus(ev, menuBar, hasMenuFocus, isRoot);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsTopFrame
- //----------------------------------------------------------------------------------------
- // IsTopFrame returns true if this frame is a sub-frame of the root frame
-
- FW_Boolean FW_CFrame::IsTopFrame(Environment *ev) const
- {
- if (IsRoot(ev))
- return TRUE;
-
- return IsSubframe(ev) && AcquireContainingFrame(ev)->IsRoot(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsSiblingFrameOf
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::IsSiblingFrameOf(Environment *ev, ODFrame* otherODFrame) const
- {
- if (otherODFrame == NULL)
- return FALSE;
-
- FW_CAcquiredODPart otherPart = otherODFrame->AcquirePart(ev);
- if (GetODPart(ev) == otherPart)
- {
- FW_CFrame* otherFrame = FW_CFrame::ODtoFWFrame(ev, otherODFrame);
- return GetPresentation(ev) == otherFrame->GetPresentation(ev);
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
- // When overridden, call inherited::FocusStateChanged FIRST
-
- void FW_CFrame::FocusStateChanged(Environment *ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- if (focus == FW_CPart::gSelectionFocusToken)
- {
- if (!newState)
- {
- /* [HLX] we have a bug in ODF. If I close the selection when I get deactivated I can't clear it anymore
- during a drag&drop. The dropped frame actives itself before I have time to clear the selection
- // Close the selection if I become deactive and the newOwner is not NULL and
- // not one of my sibling
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- if (selection)
- {
- if (newOwner != NULL && !IsSiblingFrameOf(ev, newOwner))
- selection->CloseSelection(ev);
- }
- */
- Deactivate(ev);
- }
- else
- {
- Activate(ev);
- }
-
- fPart->SetActiveFrame(ev, newState ? this : NULL);
- }
- else if (focus == FW_CPart::gMenuFocusToken)
- {
- if (newState)
- {
- InstallMenus(ev);
- fPart->HideShowFloatingWindows(ev, TRUE);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::Activate
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::Activate(Environment* ev)
- {
- FW_Boolean result = FW_CView::Activate(ev);
-
- // *LSD this part to review: which SubView should become target.
- // Should have saved a target at the last deactivate.
- if (result && this->IsEnabled(ev) && this->WantsToBeTarget(ev))
- this->BecomeTarget(ev);
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ActivateFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ActivateFrame(Environment *ev, ODFacet* activatedFacet)
- {
- if (CanBeActiveFrame(ev))
- {
- SetActiveFacet(ev, activatedFacet);
-
- if (!IsActive(ev))
- {
- // ----- Check first if the FocusSet has been changed -----
- if (fFocusSetChanged)
- {
- fFocusSet = fChangedFocusSet;
- fFocusSetChanged = FALSE;
- }
-
- // ----- Our version of RequestFocusSet returns false if the focus set is empty
- if (fFocusSet.RequestFocusSet(ev, GetODFrame(ev)))
- {
- fNeedsFoci = FALSE;
-
- FW_CFocusSetIterator ite(ev, fFocusSet);
- for (ODTypeToken token = ite.First(ev); ite.IsNotComplete(ev); token = ite.Next(ev))
- FocusStateChanged(ev, token, TRUE, NULL);
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::CanBeActiveFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::CanBeActiveFrame(Environment* ev) const
- {
- FW_ASSERT(GetWindow(ev) != NULL);
- return fCanBeActiveFrame && !GetWindow(ev)->IsFloating(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivGetFrameShapeBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivGetFrameShapeBounds(Environment* ev, FW_CRect& rect) const
- {
- FW_CAcquiredODShape aqODShape = AcquireFrameShape(ev, NULL);
- rect = FW_GetShapeBoundingBox(ev, aqODShape);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ODtoFWFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CFrame::ODtoFWFrame(Environment *ev, ODFrame* odFrame)
- {
- FW_CFrame* frame = NULL;
-
- if (odFrame)
- {
- FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)odFrame->GetPartInfo(ev);
- FW_ASSERT(framePartInfo != NULL);
- frame = framePartInfo->GetFrame();
- }
-
- return frame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
- // When overridden, call inherited::FrameShapeChanged
-
- void FW_CFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CRect frameRect;
- PrivGetFrameShapeBounds(ev, frameRect);
- SetSize(ev, frameRect.Size());
- SetExtent(ev, frameRect.Size()); // *LSD: ok?
-
- if (GetViewType(ev) == FW_CPart::gViewAsFrameToken)
- {
- #ifdef FW_BUILD_WIN
- MoveSizeShadowWindow(ev);
- #endif
- AdjustSubViews(ev);
- }
-
- UpdateUsedAndActiveShapes(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetActiveFacet
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetActiveFacet(Environment* ev, ODFacet* activeFacet)
- {
- fActiveFacet = activeFacet;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateUsedAndActiveShapes
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateUsedAndActiveShapes(Environment* ev)
- {
- // ----- Used Shape -----
- UpdateUsedShape(ev);
-
- // ----- Active Shape for everyone of my facets -----
- FW_CFrameFacetIterator iter(ev, this);
- for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
- {
- UpdateActiveShape(ev, facet);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateUsedShape
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateUsedShape(Environment* ev)
- {
- // ----- Used Shape -----
- FW_CAcquiredODShape aqUsedShape;
-
- if (fViewAs == NULL)
- {
- // ----- By default the used shape is the frame shape
- FW_CAcquiredODShape aqFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, NULL));
- aqUsedShape = AdjustUsedShape(ev, aqFrameShape);
- }
- else
- {
- aqUsedShape = fViewAs->CalcUsedShape(ev);
- }
-
- ChangeUsedShape(ev, aqUsedShape, NULL); // Passing NULL is valid
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateActiveShape
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateActiveShape(Environment* ev, ODFacet* facet)
- {
- FW_CAcquiredODShape aqActiveShape;
- FW_CAcquiredODShape aqProposedActiveShape = FW_CopyAndRelease(ev, AcquireUsedShape(ev));
-
- if (fViewAs == NULL)
- aqActiveShape = AdjustActiveShape(ev, facet, aqProposedActiveShape);
- else
- aqActiveShape = aqProposedActiveShape;
-
- facet->ChangeActiveShape(ev, aqActiveShape, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustUsedShape
- //----------------------------------------------------------------------------------------
- // suggestedUsedShape is the frame shape. The default implementation returns NULL because
- // we don't want to maintain an used shape
-
- ODShape* FW_CFrame::AdjustUsedShape(Environment* ev, ODShape* suggestedUsedShape)
- {
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustActiveShape
- //----------------------------------------------------------------------------------------
- // suggestedActiveShape is the used shape. The default implementation returns NULL because
- // we don't want to maintain an active shape
-
- ODShape* FW_CFrame::AdjustActiveShape(Environment* ev, ODFacet* facet, ODShape* suggestedActiveShape)
- {
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetFocusSet
- //----------------------------------------------------------------------------------------
- // We have to use a temporary focusSet because if the focus set is changed while the frame
- // is active and relinquishFocus is called (like in FrameRemoved) it will be called
- // with the wrong focus set
-
- void FW_CFrame::SetFocusSet(Environment* ev, const FW_CFocusSet& focusSet)
- {
- fFocusSetChanged = TRUE;
- fChangedFocusSet = focusSet;
-
- // ----- [HLX] bug in OpenDoc ???
- if (IsRoot(ev))
- {
- if (!fChangedFocusSet.Contains(ev, FW_CPart::gSelectionFocusToken))
- fChangedFocusSet.Add(ev, FW_CPart::gSelectionFocusToken);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FacetPartInfoFactory
- //----------------------------------------------------------------------------------------
-
- FW_CFacetPartInfo* FW_CFrame::FacetPartInfoFactory(Environment* ev, ODFacet* facet)
- {
- FW_CFacetPartInfo* facetPartInfo = new FW_CFacetPartInfo;
- facetPartInfo->InitFacetPartInfo(ev, facet);
- return facetPartInfo;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::RequestFrameShape
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::RequestFrameShape(Environment *ev, ODShape* shape, ODCanvas* biasCanvas)
- {
- FW_CAcquiredODShape aqOldFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, biasCanvas));
-
- FW_CAcquiredODShape aqNewFrameShape = fODFrame->RequestFrameShape(ev, shape, biasCanvas);
-
- FW_Boolean changed = !aqNewFrameShape->IsSameAs(ev, aqOldFrameShape);
-
- if (changed)
- FrameShapeChanged(ev);
-
- return changed;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FacetAdded
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetAdded FIRST
-
- void FW_CFrame::FacetAdded(Environment* ev, ODFacet* facet)
- {
- // ----- Install the newest facet as the active facet of this frame
- this->SetActiveFacet(ev, facet);
-
- // ----- Set the facet's part info -----
- FW_CFacetPartInfo *facetInfo = FacetPartInfoFactory(ev, facet);
- facet->SetPartInfo(ev, (ODInfoType)facetInfo);
-
- // ----- Create the window wrapper -----
- // ----- We have to wait for facet added because
- // ----- at FrameAdded it it too early
- FW_CAcquiredODWindow aqODWindow = fODFrame->AcquireWindow(ev);
- this->PrivCreateWindow(ev, aqODWindow); // Might not create a FW_CWindow if already has one
-
- // ----- If the Window is a floating window: remove all the foci by
- // ------ setting an empty set.
- if (aqODWindow->IsFloating(ev))
- {
- FW_CFocusSet focusSet(ev, fPart->GetSession(ev));
- SetFocusSet(ev, focusSet);
- }
-
- // ----- Create the Shadow Window for Windows
- #ifdef FW_BUILD_WIN
- CreateShadowWindow(ev);
- #endif
-
- // ----- First facet: update used shape and create the sub-views
- if(fFacetCount == 0)
- {
- UpdateUsedShape(ev);
-
- //FW_CGadgetInitializer vi(ev); *LSD replace it with CViewInitializer?
- CreateSubViews(ev);
- }
-
- // ----- Give my frame a chance to update the active shape of the facet -----
- UpdateActiveShape(ev, facet);
-
- // ----- One more facet -----
- fFacetCount++;
-
- // ----- Finally invalidate the content of the facet so it will be redrawn -----
- FW_CAcquiredODShape aqUsedShape = AcquireUsedShape(ev);
- facet->Invalidate(ev, aqUsedShape, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FacetRemoved
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetRemoved last
-
- void FW_CFrame::FacetRemoved(Environment* ev, ODFacet* odFacet)
- {
- FW_ASSERT(fFacetCount > 0);
-
- if (this->GetActiveFacet(ev) == odFacet)
- {
- FW_CFrameFacetIterator iter(ev, this);
- this->SetActiveFacet(ev, iter.First(ev));
- }
-
- // ----- Delete the facet part info -----
- FW_CFacetPartInfo* partInfo = FW_CFacetPartInfo::GetFacetPartInfo(ev, odFacet);
- delete partInfo;
- odFacet->SetPartInfo(ev, (ODInfoType)NULL);
-
- // ----- One less facet -----
- fFacetCount--;
-
- // ----- Delete the fWindow if it was the last facet -----
- if (fFacetCount == 0)
- {
- FW_ASSERT(fWindow);
- delete fWindow;
- fWindow = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::GetWindow(Environment* ev) const
- {
- return fWindow;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivAttachSourceFrame
- //----------------------------------------------------------------------------------------
- // PrivAttachSourceFrame is not called if 'sourceFrame' is NULL
-
- void FW_CFrame::PrivAttachSourceFrame(Environment* ev, FW_CFrame* sourceFrame)
- {
- FW_UNUSED(sourceFrame);
-
- FW_ASSERT(sourceFrame != NULL);
- FW_ASSERT(fPresentation == sourceFrame->GetPresentation(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasSelectionFocus()
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasSelectionFocus(Environment* ev) const
- {
- FW_CAcquiredODFrame aqODFrame = fPart->GetSession(ev)->GetArbitrator(ev)->AcquireFocusOwner(ev, FW_CPart::gSelectionFocusToken);
- return fODFrame == aqODFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ViewTypeChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ViewTypeChanged(Environment* ev,
- ODTypeToken newViewType,
- ODTypeToken oldViewType)
- {
- Invalidate(ev);
-
- if (fViewAs != NULL)
- fPresentation->ReleaseViewAs(ev, fViewAs);
- fViewAs = NULL;
-
- if (newViewType != FW_CPart::gViewAsFrameToken)
- fViewAs = fPresentation->AcquireViewAs(ev, this, newViewType);
-
- UpdateUsedAndActiveShapes(ev);
-
- Invalidate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::BuildThumbnail
- //----------------------------------------------------------------------------------------
- // By default does nothing
-
- void FW_CFrame::BuildThumbnail(Environment* ev, FW_CGraphicContext& gc, const FW_CRect& destRect)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PresentationChanged()
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PresentationChanged(Environment* ev)
- {
- // SetIdentifier(ev, GetPresentation(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SequenceChanged()
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SequenceChanged(Environment* ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivActiveWindowOnMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::PrivActiveWindowOnMouseDown(Environment* ev, ODFacet* facet, FW_Boolean clickedInFrame)
- {
- if (!GetWindow(ev)->IsFloating(ev))
- {
- FW_Boolean windowUnselected = !GetWindow(ev)->IsActive(ev);
-
- // ----- Select the window if not already selected -----
- if (windowUnselected)
- GetWindow(ev)->Select(ev);
-
- // ----- active frame on mousedown only if clicked in the frame -----
- if (clickedInFrame)
- ActivateFrame(ev, facet);
-
- // ----- If the window was unselected and I don't want the -----
- // ----- first click just return TRUE;
- if (windowUnselected && !GetFrontClicks(ev))
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleActivateEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- if (theActivateEvent.IsActivating(ev))
- {
- if (fNeedsFoci)
- ActivateFrame(ev, theActivateEvent.GetFacet(ev));
- }
- else
- {
- fNeedsFoci = IsActive(ev);
- }
-
- return FW_CView::HandleActivateEvent(ev, theActivateEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleSuspendResumeEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theResumeSuspendEvent)
- {
- if (IsRoot(ev))
- {
- // ----- We have to test that this frame belongs to the part with the menu focus
- ODArbitrator* arbitrator = fPart->GetSession(ev)->GetArbitrator(ev);
- FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
-
- if (aqODFrame != NULL)
- {
- FW_CAcquiredODPart aqODPart = aqODFrame->AcquirePart(ev);
- if (aqODPart == fPart->GetODPart(ev))
- // ----- Won't do anything if window is not a floating window -----
- GetWindow(ev)->HideShowOnActivate(ev, !theResumeSuspendEvent.IsGoingToBackground(ev));
- }
-
- }
-
- return FW_CView::HandleSuspendResumeEvent(ev, theResumeSuspendEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GeometryChanged
- //----------------------------------------------------------------------------------------
- // the geometry (clip shape or external transform) of one of my facet or one of my
- // embedding facet as changed
-
- void FW_CFrame::GeometryChanged(Environment *ev,
- ODFacet* odFacet,
- FW_Boolean clipShapeChanged,
- FW_Boolean externalTransformChanged)
- {
- FW_UNUSED(ev);
- FW_UNUSED(odFacet);
- FW_UNUSED(clipShapeChanged);
- FW_UNUSED(externalTransformChanged);
-
- #ifdef FW_BUILD_WIN
- MoveSizeShadowWindow(ev);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::OpenSelection
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::OpenSelection(Environment* ev)
- {
- // Nothing to do
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleDraw
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::HandleDraw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // if the facet doesn't have a graphicdevice it is not one of my facet anymore
- // That means that FacetRemoved has been called but my container is still trying
- // do draw me.[HLX] Might be a bug in OpenDoc. Might have been fixed in DR4
- if (FW_CFacetPartInfo::GetFacetGraphicDevice(ev, odFacet) == NULL)
- return;
-
- // FW_CAcquiredODShape aqInvalidShape(invalidShape->Copy(ev));
-
- // // InvalidShape is in frame coordinate. Tranform it to content coordinate
- // FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);
- // aqInvalidShape->InverseTransform(ev, aqTransform);
-
- #ifdef FW_BUILD_WIN
- // [HLX] bug in windows? the invalidShape is in pixels instead of points
- aqInvalidShape->Outset(ev, ff(1)); // [HLX] Because of rounding errors
- FW_CGraphicDevice *device = FW_CFacetPartInfo::GetFacetGraphicDevice(ev, odFacet);
- device->PixelToPoint(ev, aqInvalidShape);
- #endif
-
- // ATTENTION: we don't test fViewAs != NULL because if the frame was created
- // as an icon or thumbnail it may not yet have a fViewAs
- ODTypeToken viewType = GetViewType(ev);
- if (viewType == FW_CPart::gViewAsFrameToken)
- {
- FW_CView::HandleDraw(ev, odFacet, invalidShape);
- }
- else
- {
- if (fViewAs == NULL)
- fViewAs = fPresentation->AcquireViewAs(ev, this, viewType);
-
- fViewAs->Draw(ev, odFacet, invalidShape /*aqInvalidShape*/);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::Draw
- //----------------------------------------------------------------------------------------
- // invalidShape is in content coordinate
-
- void FW_CFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_UNUSED(odFacet);
- FW_UNUSED(invalidShape);
-
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseEnter
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Boolean FW_CFrame::HandleMouseEnter(Environment *ev, ODFacet* odFacet, const FW_CPoint& where)
- {
- fViewUnderCursor = GetViewContaining(ev, odFacet, where);
- FW_ASSERT(fViewUnderCursor != NULL);
-
- if (!fViewUnderCursor->AdjustCursor(ev, odFacet, where))
- FW_gArrowCursor.Select();
-
- return fViewUnderCursor->DoMouseEnter(ev, odFacet, where);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseLeave
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HandleMouseLeave(Environment *ev, ODFacet* odFacet)
- {
- FW_gArrowCursor.Select();
-
- FW_ASSERT(fViewUnderCursor != NULL);
-
- FW_Boolean result = fViewUnderCursor->DoMouseLeave(ev, odFacet);
-
- fViewUnderCursor = NULL;
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseWithin
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Boolean FW_CFrame::HandleMouseWithin(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint)
- {
- FW_CView* viewUnderCursor = GetViewContaining(ev, odFacet, theMousePoint);
- FW_ASSERT(viewUnderCursor != NULL);
-
- FW_ASSERT(fViewUnderCursor != NULL);
-
- if (viewUnderCursor != fViewUnderCursor)
- {
- fViewUnderCursor->DoMouseLeave(ev, odFacet);
-
- viewUnderCursor->DoMouseEnter(ev, odFacet, theMousePoint);
- }
- else
- viewUnderCursor->DoMouseWithin(ev, odFacet, theMousePoint);
-
- fViewUnderCursor = viewUnderCursor;
-
- if (!fViewUnderCursor->AdjustCursor(ev, odFacet, theMousePoint))
- FW_gArrowCursor.Select();
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Boolean FW_CFrame::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint)
- {
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetODPart()
- //----------------------------------------------------------------------------------------
-
- ODPart* FW_CFrame::GetODPart(Environment* ev) const
- {
- return fPart->GetODPart(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ExternalizeFrame
- //----------------------------------------------------------------------------------------
- // When overriding call inherited first
-
- void FW_CFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CByteArray byteArray(&fContentViewLocation, sizeof(FW_CPoint));
- storageUnitView->SetValue(ev, byteArray);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::InternalizeFrame
- //----------------------------------------------------------------------------------------
- // When overriding call inherited first
-
- void FW_CFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CByteArray byteArray;
- storageUnitView->GetValue(ev, sizeof(FW_CPoint), byteArray);
- byteArray.CopyBuffer(&fContentViewLocation, sizeof(FW_CPoint));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetContentView()
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetContentView(Environment* ev, FW_CView* view)
- {
- // SetContentView can only be called once to set fContentView
- // (fContentView was initialized to the frame itself)
- FW_ASSERT(IsContentView(ev) == TRUE);
-
- PrivSetIsContentView(ev, FALSE);
- fContentView = view;
-
- // Move the internal transform to be relative to the new ContentView
- FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);
-
- // ----- Remove the previous position -----
- FW_CPoint offset = -fContentViewLocation;
- aqTransform->MoveBy(ev, (ODPoint*)&offset);
-
- FW_CAcquiredODTransform aqViewToFrameTransform(view->AcquireViewToFrameTransform(ev));
- aqTransform->PostCompose(ev, aqViewToFrameTransform);
-
- ChangeInternalTransform(ev, aqTransform);
-
- PrivContentViewLocationChanged(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetContentExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::GetContentExtent(Environment* ev, FW_CPoint& extent) const
- {
- extent = GetContentView(ev)->GetExtent(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AcquireContentShape
- //----------------------------------------------------------------------------------------
- // return the content shape in Frame coordinates
-
- ODShape* FW_CFrame::AcquireContentShape(Environment *ev)
- {
- FW_CView* contentView = GetContentView(ev);
-
- FW_CRect contentRect(contentView->GetBounds(ev));
- contentRect.Place(FW_kFixed0, FW_kFixed0);
-
- contentView->ViewToFrame(ev, contentRect);
- return FW_NewODShape(ev, contentRect);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AddScrollingView
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AddScrollingView(Environment* ev, const FW_CView *view)
- {
- FW_ASSERT(view->UseContentSpaceInX(ev) || view->UseContentSpaceInY(ev));
-
- if (fScrollingViews == NULL) {
- fScrollingViews = new FW_CPrivOrderedCollection;
- }
- else {
- FW_ASSERT(fScrollingViews->Contains(this) == FALSE);
- }
-
- fScrollingViews->AddLast((FW_CView*) view);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::RemoveScrollingView
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::RemoveScrollingView(Environment* ev, const FW_CView *view)
- {
- // fScrollingViews is already NULL when frame is being deleted
- if(fScrollingViews != NULL) {
- FW_ASSERT(fScrollingViews->Contains((FW_CView*)view));
- fScrollingViews->Remove((FW_CView*)view);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AcquireContentScrollShape
- //----------------------------------------------------------------------------------------
- // This returns the shape (in Frame coord.) composed of the ContentView + all the views
- // scrolling in X or Y with the content.
- // [LSD] if scroll is not purely X or Y we limit the shape to the ContentView for now.
- // Other views will have to scroll independantly
-
- ODShape* FW_CFrame::AcquireContentScrollShape(Environment* ev, const FW_CPoint& by)
- {
- // Get the contentView first
- ODShape* scrollShape = ::FW_NewODShape(ev, FW_CRect(FW_kZeroPoint, fContentView->GetSize(ev)));
- fContentView->ViewToFrame(ev, scrollShape);
-
- if (by.IntX() == 0 || by.IntY() == 0) {
- FW_Boolean verticalScroll = (by.IntX() == 0);
- FW_CScrollingViewIterator ite(ev, this);
- for (FW_CView* subview = ite.First(ev); ite.IsNotComplete(ev); subview = ite.Next(ev))
- {
- if (subview->IsVisible(ev))
- {
- if ((verticalScroll && subview->UseContentSpaceInX(ev)) ||
- (!verticalScroll && subview->UseContentSpaceInY(ev))) continue;
-
- FW_CAcquiredODShape aqScrollShape = ::FW_NewODShape(ev, FW_CRect(FW_kZeroPoint, subview->GetSize(ev)));
- subview->ViewToFrame(ev, aqScrollShape);
-
- scrollShape->Union(ev, aqScrollShape);
- }
- }
- }
-
- return scrollShape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivReleaseODFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivReleaseODFrame(Environment *ev)
- {
- FW_ASSERT(fODFrame != NULL);
- fODFrame->Release(ev);
- fODFrame = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::BeginRelinquishFocus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::BeginRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
- {
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AbortRelinquishFocus
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AbortRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
- {
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CFrame::CommitRelinquishFocus
- //---------------------------------------------------------------------------------------
-
- void FW_CFrame::CommitRelinquishFocus(Environment *ev,
- ODTypeToken focus,
- ODFrame* proposedFrame)
- {
- FocusStateChanged(ev, focus, FALSE, proposedFrame);
-
- FW_Boolean doIt = (proposedFrame == NULL);
- if (!doIt)
- {
- FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
- doIt = aqODPart != fPart->GetODPart(ev);
- }
-
- if (doIt)
- {
- if (focus == FW_CPart::gMenuFocusToken)
- fPart->HideShowFloatingWindows(ev, FALSE);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ClonePartInfo
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ClonePartInfo(Environment* ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scope)
- {
- // Don't do anything for now
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AddConnection
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AddConnection(Environment*ev, FW_CInterest& interest)
- {
- if (fConnection == NULL) {
- fConnection = new FW_CHandleFunctionConnection(this);
- fConnection->Connect();
- }
-
- fConnection->AddInterest(interest);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleNotification
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::HandleNotification(const FW_CNotification& notification)
- {
- // *LSD: check that we're dealing only with scrolling
- Environment *ev = somGetGlobalEnvironment();
- ODSession* session = GetFrame(ev)->GetPart(ev)->GetSession(ev);
- ODTypeToken scrollNotificationToken = session->Tokenize(ev, FW_CScrollNotification::kName);
-
- if (notification.GetName() != scrollNotificationToken) {
- return;
- }
-
- const FW_CScrollNotification& scrollNfy = (FW_CScrollNotification&) notification;
-
- // Set scrollBy to opposite value of scrolling to move the internal transform
- FW_CPoint scrollBy;
-
- if (scrollNfy.GetDirection() == FW_CScrollNotification::kVertical)
- scrollBy.Set(FW_kFixed0, -scrollNfy.GetDelta());
- else
- scrollBy.Set(-scrollNfy.GetDelta(), FW_kFixed0);
-
- FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);
- ODPoint odScrollBy = scrollBy;
- aqTransform->MoveBy(ev, &odScrollBy);
-
- // *LSD2 hack can be removed after DR4 ?
- #ifdef FW_BUILD_MAC
- // [HLX] Temporary because of a bug in OpenDoc
- // ChangeInternalTransform changes the clip and the origin and does not restore it
- GrafPtr port;
- ::GetPort(&port);
- Point origin;
- origin.h = port->portRect.left;
- origin.v = port->portRect.top;
- ODRgnHandle clipRgn = ::NewRgn();
- ::GetClip(clipRgn);
- #endif
-
- ChangeInternalTransform(ev, aqTransform);
-
- #ifdef FW_BUILD_MAC
- // [HLX] Temporary because of a bug in OpenDoc
- ::SetPort(port);
- ::SetClip(clipRgn);
- ::DisposeRgn(clipRgn);
- ::SetOrigin(-origin.h, -origin.v);
- #endif
-
- // ----- Invalid view cached transforms -----
- PrivInvalidateCachedTransforms(ev);
- }
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::CreateShadowWindow
- //----------------------------------------------------------------------------------------
- // Create a transparent Window so that we get a chance to handle messages sent by Windows
- // controls to their parent Window.
-
- void FW_CFrame::CreateShadowWindow(Environment *ev)
- {
- ODPlatformWindow parentHWnd = fWindow->GetPlatformWindow(ev);
- #ifdef FW_BUILD_WIN16
- HINSTANCE hInstance = (HINSTANCE)GetWindowWord(parentHWnd, GWW_HINSTANCE);
- #endif
- #ifdef FW_BUILD_WIN32
- HINSTANCE hInstance = (HINSTANCE)GetWindowLong(parentHWnd, GWL_HINSTANCE);
- #endif
-
- WNDCLASS wc;
-
- if (!GetClassInfo(hInstance, "ShadowWindow", &wc))
- {
- wc.style = CS_DBLCLKS;
- wc.lpfnWndProc = ShadowWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 4;
- wc.hInstance = hInstance;
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "ShadowWindow";
-
- if (!RegisterClass(&wc))
- return;
- }
-
- fShadowWindow = CreateWindowEx(WS_EX_TRANSPARENT, "ShadowWindow", "",
- WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
- parentHWnd, NULL, hInstance, (LPSTR) this);
- MoveSizeShadowWindow(ev);
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::MoveSizeShadowWindow
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::MoveSizeShadowWindow(Environment* ev)
- {
- if (fShadowWindow != NULL)
- {
- ODFacet* facet = GetActiveFacet(ev);
- FW_CAcquiredODShape aqShape(FW_CopyAndRelease(ev, facet->AcquireActiveShape(ev, NULL)));
- FW_CAcquiredODTransform aqExternalTransform = facet->AcquireExternalTransform(ev, NULL);
- aqShape->Transform(ev, aqExternalTransform);
-
- FW_CRect bBox;
- aqShape->GetBoundingBox(ev, &bBox);
-
- // Shape bounding box is in 72dpi, need to convert to pixels
- if(!IsRoot(ev))
- {
- // [KVV] ??? This is only necessary for non-root frames
-
- HDC hDC = ::GetDC(NULL);
- int xRes = ::GetDeviceCaps(hDC, LOGPIXELSX);
- int yRes = ::GetDeviceCaps(hDC, LOGPIXELSY);
- ::ReleaseDC(NULL, hDC);
-
- FW_Fixed xScale = FW_FixDiv(ff(xRes), ff(72));
- FW_Fixed yScale = FW_FixDiv(ff(yRes), ff(72));
-
- bBox.left = FW_FixMul(bBox.left, xScale);
- bBox.top = FW_FixMul(bBox.top, yScale);
- bBox.right = FW_FixMul(bBox.right, xScale);
- bBox.bottom = FW_FixMul(bBox.bottom,yScale);
- }
-
- FW_PlatformRect wndRect;
- bBox.AsPlatformRect(wndRect);
-
- ::MoveWindow(fShadowWindow, wndRect.left, wndRect.top,
- wndRect.right - wndRect.left, wndRect.bottom - wndRect.top, TRUE);
- }
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ShadowWindowProc
- //----------------------------------------------------------------------------------------
-
- LRESULT CALLBACK FW_CFrame::ShadowWindowProc(HWND hWnd, UINT msg,
- WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- #ifdef FW_DEBUG
- // ----- Frame the shadow window for ease of debugging
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hDC = ::BeginPaint(hWnd, &ps);
-
- if(::GetPrivateProfileInt("Debug", "ShadowWindow Outline", FALSE, "ODF.ini"))
- {
- static const char pattern[8][2] =
- {
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 }
- };
-
- HBITMAP hBitmap = ::CreateBitmap(8, 8, 1, 1, pattern);
-
- HBRUSH hBrush = ::CreatePatternBrush(hBitmap);
-
- ::SetTextColor(hDC, RGB(0xFF, 0x00, 0xFF));
-
- RECT rc;
- ::GetClientRect(hWnd, &rc);
-
- HRGN hRgn = ::CreateRectRgnIndirect(&rc);
-
- ::FrameRgn(hDC, hRgn, hBrush, 3, 3);
-
- ::DeleteObject(hRgn);
- ::DeleteObject(hBrush);
- ::DeleteObject(hBitmap);
- }
-
- ::EndPaint(hWnd, &ps);
- }
- return 0;
- #endif
-
- case WM_CREATE:
- SetWindowLong(hWnd, 0, (long) ((LPCREATESTRUCT) lParam)->lpCreateParams);
- return 0;
-
- case WM_NCHITTEST:
- return HTTRANSPARENT;
-
- case WM_COMMAND:
- switch (HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- HWND hButton = HWND(lParam);
-
- // If this is a window
- if (hButton != NULL && ::IsWindow(hButton))
- {
- // Get the scroll bar helper
- FW_CPrivWinButtonHelper* buttonHelper =
- FW_DYNAMIC_CAST(FW_CPrivWinButtonHelper, FW_CPrivWinControlHelper::HWNDToHelper(hButton));
-
- // Tell the button to update itself and the pane
- buttonHelper->HandleButtonMessage();
- return 0L;
- }
- }
- break;
- }
- break;
-
- case WM_HSCROLL:
- case WM_VSCROLL:
- {
- HWND hBar = HWND(lParam);
-
- // If this is not a scroll bar control, but a Windows
- // window scroll bar, pass it to Windows wndproc
- if (hBar == NULL)
- {
- FW_DEBUG_MESSAGE("Warning: ODF does not use Window scroll bars!");
- break;
- }
-
- // If this is a window
- if (hBar != NULL && ::IsWindow(hBar))
- {
- // Get the scroll bar helper
- FW_CPrivWinScrollBarHelper* sbHelper =
- FW_DYNAMIC_CAST(FW_CPrivWinScrollBarHelper, FW_CPrivWinControlHelper::HWNDToHelper(hBar));
-
- // Tell the scroll bar to update itself and the pane
- if (sbHelper != NULL)
- {
- sbHelper->HandleScrollMessage(LOWORD(wParam), HIWORD(wParam));
- return 0L;
- }
- }
- break;
- }
- }
-
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasPropertyOnClipboard
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasPropertyOnClipboard(Environment* ev, ODPropertyName propertyName, ODValueType type)
- {
- ODSession* session = GetPart(ev)->GetSession(ev);
- ODArbitrator* arbitrator = session->GetArbitrator(ev);
- FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::gClipboardFocusToken);
-
- if ((aqODFrame == fODFrame) || (arbitrator->RequestFocus(ev, FW_CPart::gClipboardFocusToken, fODFrame)) )
- {
- ODStorageUnit* su = session->GetClipboard(ev)->GetContentStorageUnit(ev);
- return su->Exists(ev, propertyName, type, 0);
- }
- else
- {
- return FALSE;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivContentViewLocationChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivContentViewLocationChanged(Environment* ev)
- {
- FW_CAcquiredODTransform aqViewToFrameTransform = GetContentView(ev)->AcquireViewToFrameTransform(ev);
- aqViewToFrameTransform->GetOffset(ev, (ODPoint*)&fContentViewLocation);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewPrintHandler
- //----------------------------------------------------------------------------------------
-
- FW_CPrintHandler* FW_CFrame::NewPrintHandler(Environment* /* ev */)
- {
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsCurrentlyPrintable
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::IsCurrentlyPrintable(Environment* /* ev */) const
- {
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetPrintContentExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::GetPrintContentExtent(Environment* ev, FW_CPoint& extent) const
- {
- GetContentExtent(ev, extent);
- FW_ASSERT(extent.x);
- FW_ASSERT(extent.y);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetPrintJobTitle
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::GetPrintJobTitle(Environment* ev, FW_CString& jobTitle) const
- {
- GetPart(ev)->GetPartName(ev, jobTitle);
- }
-
- //========================================================================================
- // CLASS FW_CScrollingViewIterator
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CScrollingViewIterator::FW_CScrollingViewIterator
- //----------------------------------------------------------------------------------------
-
- FW_CScrollingViewIterator::FW_CScrollingViewIterator(Environment* ev, const FW_CFrame *container) :
- fIterator(NULL)
- {
- if (container->fScrollingViews)
- fIterator = new FW_COrderedCollectionIterator(container->fScrollingViews);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CScrollingViewIterator::~FW_CScrollingViewIterator
- //----------------------------------------------------------------------------------------
-
- FW_CScrollingViewIterator::~FW_CScrollingViewIterator()
- {
- FW_START_DESTRUCTOR
-
- delete fIterator;
- }
-